class Exploitdb < Formula
  desc "Database of public exploits and corresponding vulnerable software"
  homepage "https://www.exploit-db.com/"
  url "https://github.com/offensive-security/exploitdb.git",
      tag:      "2021-09-08",
      revision: "528f2d809f81d972c2d3deaf4940abaf384fde8f"
  version "2021-09-08"
  license "GPL-2.0-or-later"
  head "https://github.com/offensive-security/exploitdb.git"

  bottle do
    sha256 cellar: :any_skip_relocation, arm64_big_sur: "e13e3fc0d7bda25f5c8b97bee1e1402e759678d6a01843f6ed82decad39ef6e1"
    sha256 cellar: :any_skip_relocation, big_sur:       "b6cdca07d35da2e0c564a6f106fe7fcb0a602ae931074e6026bb489ed738e5fc"
    sha256 cellar: :any_skip_relocation, catalina:      "7c1493fa4f1014e5c523f940463db4330784e1ca5aa2531d4e8d06567234189d"
    sha256 cellar: :any_skip_relocation, mojave:        "3edc2f238b68ac07eb117f156d28b3d17a58889abbe95a40d7a33ed047d78ade"
    sha256 cellar: :any_skip_relocation, x86_64_linux:  "924697b15b1a2f74947f879c6512bc3d3cbbb998d58e15df2040d9c3a07a6abb"
  end

  def install
    inreplace "searchsploit",
              "rc_file=\"\"", "rc_file=\"#{etc}/searchsploit_rc\""

    optpath = opt_share/"exploitdb"
    inreplace ".searchsploit_rc" do |s|
      s.gsub! "\"/opt/exploitdb\"", optpath
      s.gsub! "\"/opt/exploitdb-papers\"", "#{optpath}-papers"
    end

    bin.install "searchsploit"
    etc.install ".searchsploit_rc" => "searchsploit_rc"

    pkgshare.install %w[.git exploits files_exploits.csv files_shellcodes.csv
                        shellcodes]
  end

  test do
    system "#{bin}/searchsploit", "sendpage"
  end
end
